package cn.group01.git.controller;

import cn.group01.git.annotations.LogOperation;
import cn.group01.git.common.Operation;
import cn.group01.git.common.ResponseResult;
import cn.group01.git.dto.OutportPageDTO;
import cn.group01.git.entity.GoodsOutport;
import cn.group01.git.service.GoodsOutportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
/**
 * @description:
 * @author: 张庆昌
 * @date: 2023/7/13 11:14
 **/
@RestController
@RequestMapping("outport")
public class OutportController {
    @Autowired
    private GoodsOutportService goodsOutportService;

    // 出库数据分页查询
    @GetMapping("list")
    @LogOperation(description = Operation.SELECT,model = "出库模块")
    public ResponseResult getList(OutportPageDTO OutportPageDTO){
        System.out.println("========查询出库信息=======");
        return goodsOutportService.getList(OutportPageDTO);
    }
    // 添加出库数据
    @PostMapping("add")
    @LogOperation(description = Operation.ADD,model = "出库模块")
    public ResponseResult add(@RequestBody GoodsOutport goodsOutport){
        System.out.println("========添加出库信息=======");
        return goodsOutportService.add(goodsOutport);
    }
    // 根据id查出库信息
    @GetMapping("getById")
    @LogOperation(description = Operation.SELECT,model = "出库模块")
    public GoodsOutport getById(Integer id){
        System.out.println("========根据id查出库信息=======");
        return goodsOutportService.getById(id);
    }
    @PostMapping("edit")
    @LogOperation(description = Operation.UPDATE,model = "出库模块")
    public ResponseResult edit(@RequestBody GoodsOutport goodsOutport){
        System.out.println("========编辑出库信息=======");
        return goodsOutportService.edit(goodsOutport);
    }
    @GetMapping("delete")
    @LogOperation(description = Operation.DELETE,model = "出库模块")
    public ResponseResult batchDelete(Integer ids[]){
        System.out.println("========删除出库信息=======");
        return goodsOutportService.batchDelete(ids);
    }
    @GetMapping("export")
    @LogOperation(description = Operation.OTHER,model = "出库模块")
    public void export(OutportPageDTO outportPageDTO,HttpServletResponse response){
        System.out.println("========导出出库记录=======");
        goodsOutportService.export(outportPageDTO,response);
    }
}
